package com.id.supaclean.ui.junk

import android.widget.ImageView
import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.lifecycleScope
import com.id.supaclean.R
import com.id.supaclean.common.BaseFragment
import kotlinx.coroutines.delay

/**
 * Created by YiGo on 2022/6/14.
 */
class ScanFragment : BaseFragment() {
    override fun layoutId(): Int = R.layout.fragment_scan

    private val viewModel by lazy { ViewModelProvider(this.requireActivity()).get(JunkViewModel::class.java) }

    override fun initView() {
        view?.findViewById<ImageView>(R.id.scan_fragment_back_iv)?.setOnClickListener {
            activity?.finish()
        }

        view?.findViewById<ImageView>(R.id.scan_fragment_stop_scan_lav)?.setOnClickListener {
            activity?.finish()
        }
    }

    override fun initEvent() {
        super.initEvent()
        lifecycleScope.launchWhenResumed {
            viewModel.initData()
            delay(2000)
            navigate(R.id.action_scanFragment_to_cleanFragment)
        }
    }

    override fun getNavigateId(): Int = R.id.scanFragment


}